<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>修改xxx</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../static/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="../static/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20200727" rel="stylesheet"/>
    <link href="../static/css/animate.css" rel="stylesheet"/>
    <link href="../static/css/style.css?v=20200903" rel="stylesheet"/>
    <link href="../static/ruoyi/css/ry-ui.css?v=4.4.0" rel="stylesheet"/>
    <link href="../static/ajax/libs/datapicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
    <link href="../static/ajax/libs/summernote/summernote.css" rel="stylesheet"/>
    <link href="../static/ajax/libs/summernote/summernote-bs3.css" rel="stylesheet"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-comment-edit">
            <input name="id" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">内容</label>
                <div class="col-sm-8">
                    <input type="hidden" class="form-control">
                    <div class="summernote" id="content"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="isDeleted">
                        <option value="">正常</option>
                        <option value="">删除</option>
                        <option value="">下架</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
    <script src="../static/js/jquery.min.js"></script>
    <script src="../static/js/bootstrap.min.js"></script>
    <!-- bootstrap-table 表格插件 -->
    <script src="../static/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20200727"></script>
    <script src="../static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20200727"></script>
    <script src="../static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js?v=20200727"></script>
    <!-- jquery-validate 表单验证插件 -->
    <script src="../static/ajax/libs/validate/jquery.validate.min.js"></script>
    <script src="../static/ajax/libs/validate/messages_zh.min.js"></script>
    <script src="../static/ajax/libs/validate/jquery.validate.extend.js"></script>
    <!-- jquery-validate 表单树插件 -->
    <script src="../static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
    <!-- 遮罩层 -->
    <script src="../static/ajax/libs/blockUI/jquery.blockUI.js"></script>
    <script src="../static/ajax/libs/iCheck/icheck.min.js"></script>
    <script src="../static/ajax/libs/layer/layer.min.js"></script>
    <script src="../static/ajax/libs/layui/layui.js"></script>
    <script src="../static/ruoyi/js/common.js?v=4.4.0"></script>
    <script src="../static/ruoyi/js/ry-ui.js?v=4.4.0"></script>

    <script src="../static/ajax/libs/datapicker/bootstrap-datetimepicker.min.js"></script>
    <script src="../static/ajax/libs/summernote/summernote.min.js"></script>
    <script src="../static/ajax/libs/summernote/summernote-zh-CN.js"></script>
    <script type="text/javascript">
        let ctx = storage.get('ctx')

        let prefix = ctx + "comment";

        let id = $.url.param('id')
        console.log(id)
        let url = prefix + '/get.do?id=' + id
        $.operate.get(url, function (res) {
            console.log(res) // 用 js 把查到的东西填充到表单中
        })

        $("#form-comment-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/update.do", $('#form-comment-edit').serialize());
            }
        }

        $("input[name='time']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
							var obj = this;
							var data = new FormData();
							data.append("file", files[0]);
							$.ajax({
								type: "post",
								url: ctx + "common/upload.do",
								data: data,
								cache: false,
								contentType: false,
								processData: false,
								dataType: 'json',
								success: function(result) {
									if (result.code == web_status.SUCCESS) {
										$('#' + obj.id).summernote('insertImage', result.url);
									} else {
										$.modal.alertError(result.msg);
									}
								},
								error: function(error) {
									$.modal.alertWarning("图片上传失败。");
								}
							});
						}
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>